package models

import (
	"gitee.com/sansaniot/ssiot-core/httpmvc/model"

	dto "ssadmin/common/query"
	"ssadmin/internal/admin/models/query"
)

type SysConf struct {
	Key    string `json:"key" gorm:"primaryKey;type:varchar(255)"`
	Value  string `json:"value" gorm:"type:text"`
	Remark string `json:"remark" gorm:"type:text"`

	model.Model
}

func (SysConf) TableName() string {
	return "sys_conf"
}

func (e *SysConf) Generate() interface{} {
	o := *e
	return &o
}

func (e *SysConf) GetByKey(key string) error {
	return e.FindOne(e, dto.MakeCondition(query.SysConfQuery{Key: key}))
}

func (e *SysConf) GetByKeyList(keys []string) ([]SysConf, error) {
	list := make([]SysConf, 0)
	err := e.FindList(&list, dto.MakeCondition(query.SysConfQuery{KeyIn: keys}))
	return list, err
}
